package cn.lvji.springboot.learn4.repository;

import cn.lvji.springboot.learn4.entity.Scenic;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface ScenicRepository extends JpaRepository<Scenic,Long> {
    @Query("select s from Scenic s where s.name=?1 and s.id=?2")
    Scenic findScenic(String name, Long id);

    @Query("select s from Scenic s where s.name like :name")
    List<Scenic> findByName(String name);

    @Modifying
    @Query("update Scenic s set s.status=2 where s.id=?1")
    int closedById(Long id);

    List<Scenic> pageByName(String name, Pageable pageable);
}
